/*
 * Copyright 2011 MCA
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.mca.qmass.http.qcache.events;

import org.mca.qmass.core.QMass;
import org.mca.qmass.core.Service;
import org.mca.qmass.core.event.Event;
import org.mca.qmass.core.event.EventHandler;
import org.mca.qmass.http.qcache.services.SessionEventsService;

/**
 * User: malpay
 * Date: 23.May.2011
 * Time: 11:42:02
 *
 * Handler for session attribute changes.
 */
public class BindingEventHandler  implements EventHandler {
    @Override
    public EventHandler handleEvent(QMass qmass, Service service, Event event) {
        SessionEventsService ses = (SessionEventsService) service;
        BindingEvent be = (BindingEvent) event;
        if(event instanceof AttributeAddEvent) {
            ses.doAttributeAdded(be.getName(),be.getValue());
        } else if(event instanceof AttributeRemoveEvent) {
            ses.doAttributeRemoved(be.getName());
        } 
        return this; 
    }
}
